React tips

  • 在react中使用map函数

    1
    2
    3
    4
    5
    6
    7
    8
    9
     const numbers = [1, 2, 3, 4, 5];
    const listItems = numbers.map((numbers) =>
    <li>{numbers}</li>
    );

    ReactDOM.render(
    <ul>{listItems}</ul>,
    document.getElementById('example')
    );